//
//  JumpHelper.swift
//  HuaYun
//
//  Created by Mac on 2019/2/21.
//  Copyright © 2019 xyxorigation. All rights reserved.
//

import UIKit

class JumpHelper: NSObject {
    static var shared = JumpHelper()
    
    var topmost: UIViewController?{
        get{
            if let window = UIApplication.shared.delegate?.window {
                if let rootVC = window?.rootViewController {
                    if rootVC is UITabBarController {
                        if rootVC.presentedViewController != nil {
                            return rootVC.presentedViewController
                        }
                        //找到当前控制器，并跳转
                        let tab = rootVC as! UITabBarController
                        if let current = tab.selectedViewController as? UINavigationController {
                            return current
                        }
                    } else if rootVC is UINavigationController {
                        let navi = rootVC as! UINavigationController
                        return navi
                    }
                }
            }
            return nil
        }
    }
    
    func push(vc: UIViewController) -> Void {
//        self.topmost?.push(dest: vc)
    }
}
